package cn.woochen.functionwidget

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import cn.woochen.functionwidget.sample.SdkActivity
import cn.woochen.functionwidget.sample.TestActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), View.OnClickListener {
    override fun onClick(v: View?) {
        when (v) {
            btn_sdk -> {
                start(SdkActivity::class.java)
            }
            btn_ui -> {

            }
            btn_util -> {
                start(TestActivity::class.java)
            }

        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initView()
    }

    private fun initView() {
      /*  if (Build.VERSION.SDK_INT >= 23) {
            if (!Settings.canDrawOverlays(this)) {
                //若没有权限，提示获取.
                val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
                Toast.makeText(this, "需要取得权限以使用悬浮窗", Toast.LENGTH_SHORT).show()
                startActivityForResult(intent,100)
            }
        }*/
        btn_sdk.setOnClickListener(this)
        btn_ui.setOnClickListener(this)
        btn_util.setOnClickListener(this)
    }


    private fun start(clazz: Class<*>) {
        val intent = Intent(this, clazz)
        startActivity(intent)
    }
}
